<template>
  <div class="basic-layout">
    <el-container class="container">
      <el-aside class="aside" :width="isCollapse ? '70px' : '260px'">
        <global-aside :collapse="isCollapse" />
      </el-aside>
      <el-container>
        <el-header class="header" height="90px">
          <global-header :collapse="isCollapse" @collapse="isCollapse = $event" />
        </el-header>
        <el-main class="main">
          <el-scrollbar height="calc(100vh - 90px)">
            <div class="main-content">
              <router-view v-slot="{ Component }">
                <transition name="slide-fade" mode="out-in">
                  <component :is="Component" />
                </transition>
              </router-view>
            </div>
          </el-scrollbar>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue"
import GlobalAside from "@/components/layout/GlobalAside.vue"
import GlobalHeader from "@/components/layout/GlobalHeader.vue"

const isCollapse = ref(false)
</script>

<style lang="scss" scoped>
.basic-layout {
  .container {
    min-height: 100vh;
    background-color: var(--color-bg-second);
  }

  .aside {
    padding: 20px 0;
    color: var(--color-white);
    background-color: var(--color-bg-aside);
    transition: width 0.3s ease;
  }

  .header {
    background-color: var(--color-bg-primary);
  }

  .main {
    padding: 0;
  }

  .main-content {
    margin: 20px;
  }

  /* 进入动画 */
  .slide-fade-enter-active {
    transition: all 0.2s ease-out;
  }

  /* 离开动画 */
  .slide-fade-leave-active {
    transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
  }

  /* 进入前的状态 */
  .slide-fade-enter-from {
    transform: translateX(-20px);
    opacity: 0;
  }

  /* 进入后的状态 */
  .slide-fade-enter-to {
    transform: translateX(0);
    opacity: 1;
  }

  /* 离开前的状态 */
  .slide-fade-leave-from {
    transform: translateX(0);
    opacity: 1;
  }

  /* 离开后的状态 */
  .slide-fade-leave-to {
    transform: translateX(20px);
    opacity: 0;
  }
}
</style>
